<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "task_repair".
 *
 * @property int $id
 * @property int $task_id 任务id
 * @property int $repair_id 维修队id
 * @property int $user_id 维修员id
 * @property string $start_imgs 维修前图片
 * @property string $finsh_imgs 维修成功图片
 * @property string $start_content 维修前情况详情
 * @property string $finsh_content 维修结束情况说明
 * @property string $lng 经度
 * @property string $lat 纬度
 * @property int $arrive_at 预计到达时间
 * @property int $state 维修状态
 * @property string $remark 备注
 * @property int $admin_assign 是否是管理员派单
 * @property int $status 状态
 * @property int $created_at 创建时间
 * @property int $finsh_at 完成时间
 * @property int $go_at 出发时间
 * @property int $arrive_at_real 实际到达时间
 * @property int $cancel_at 取消时间
 */
class TaskRepair extends Base
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'task_repair';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['task_id', 'repair_id', 'user_id', 'arrive_at', 'state', 'admin_assign', 'status', 'created_at', 'finsh_at', 'go_at', 'arrive_at_real', 'cancel_at'], 'integer'],
            [['start_imgs', 'finsh_imgs', 'start_content', 'finsh_content', 'remark'], 'string'],
            [['lng', 'lat', 'estimate_distance', 'estimate_time'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'task_id' => 'Task ID',
            'repair_id' => 'Repair ID',
            'user_id' => 'User ID',
            'start_imgs' => 'Start Imgs',
            'finsh_imgs' => 'Finsh Imgs',
            'start_content' => 'Start Content',
            'finsh_content' => 'Finsh Content',
            'lng' => 'Lng',
            'lat' => 'Lat',
            'arrive_at' => 'Arrive At',
            'state' => 'State',
            'remark' => 'Remark',
            'admin_assign' => 'Admin Assign',
            'status' => 'Status',
            'created_at' => 'Created At',
            'finsh_at' => 'Finsh At',
            'go_at' => 'Go At',
            'arrive_at_real' => 'Arrive At Real',
            'cancel_at' => 'Cancel At',
        ];
    }

    public function getUser(){
        return $this->hasOne(User::class, ['id' => 'user_id']);
    }

    public function getTask(){
        return $this->hasOne(Task::class, ['id' => 'task_id']);
    }

    public function getRepair(){
        return $this->hasOne(Repair::class, ['id' => 'repair_id']);
    }
}
